#ifndef _CTILELAYER_H
#define _CTILELAYER_H

#include "Global Variables.h"
#include <vector>
#include "CTexture.h"
#include "CAnimatedObject.h"


class CTileLayer
{
public:
	enum MAP_TYPE { MAP_TYPE_NORMAL = 0 ,
						MAP_TYPE_ROTATE_LEFT = 1 ,
						MAP_TYPE_ROTATE_UP = 2 ,
						MAP_TYPE_ROTATE_RIGHT = 3 ,
						MAP_TYPE_COUNT = 4 };
	struct MAP
	{
		int		**map;
		int		  column;
		int		  row;
	};
	//--------------------------------------------//
	//	Constructor and Destructor for this class //
	//--------------------------------------------//
	CTileLayer();
	CTileLayer( CTexture* pImage , int Column , int Row , int CellSize );
	virtual ~CTileLayer();

	//--------------------------------//
	//	Public methods for this class //
	//--------------------------------//
	void	SetTiled				( CTexture* pImage );
	void	SetCell					( int Row , int Column , int TileIndex );
	void	SetCurrentType			( MAP_TYPE Type );
	void	DrawMap					( RECT area , LPD3DXSPRITE pSpriteHandler );
	void	DrawMap					( int centerX , int centerY );
	void	DrawCell				( int TileIndex , int posX , int posY  );
	void	Rotate					( );

	int		GetCell					( int Column , int Row );
	int		GetCellSize				( );
	int		GetColumn				( );
	int		GetRow					( );
	bool	isCollision				( RECT objRect );
	bool	LimitRect				( RECT camRect );

	void	Release					( );
	void	Reset					( int Type , int Col , int Row );

	static	bool	CollisionCheck	( CAnimatedObject* pObject , LPVOID pContext );
protected:
	//-----------------------------------//
	//	Private Variables for this class //
	//-----------------------------------//
	MAP					*m_pMap;
	MAP_TYPE			 m_nCurrType;
	int					 m_nCellSize;
	int					 m_nNumCellWidth;
	int					 m_nNumCellHeight;
	float				 m_fAngle;
	CTexture*			 m_pTileImage;
	D3DXMATRIX			 m_mtxTranform;

	//----------------------------------//
	//	Private methods for this class	//
	//----------------------------------//
	void	InitMap				(int Type , int Col , int Row );
	void	ReleaseMap			(int Type , int Col , int Row );
};



#endif